package com.atguigu.szdz.dcsyl.config;

import com.atguigu.szdz.dcsyl.Filter.MyLogFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<MyLogFilter> registerLogFilter(RedisTemplate<String, Object> redisTemplate) {
        FilterRegistrationBean<MyLogFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new MyLogFilter(redisTemplate));
        registrationBean.addUrlPatterns("/*"); // 指定过滤路径
//        registrationBean.addInitParameter("exclusions", "/sys/login");
        registrationBean.setOrder(1); // 设置执行顺序，值越小优先级越高
        return registrationBean;
    }
}
